using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using abpdemo.Configuration;
using abpdemo.Web;

namespace abpdemo.EntityFrameworkCore
{
    /* This class is needed to run "dotnet ef ..." commands from command line on development. Not used anywhere else */
    public class abpdemoDbContextFactory : IDesignTimeDbContextFactory<abpdemoDbContext>
    {
        public abpdemoDbContext CreateDbContext(string[] args)
        {
            var builder = new DbContextOptionsBuilder<abpdemoDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            abpdemoDbContextConfigurer.Configure(builder, configuration.GetConnectionString(abpdemoConsts.ConnectionStringName));

            return new abpdemoDbContext(builder.Options);
        }
    }
}
